<template>
  <div class="ExartTable-content">
    <div class="table_box">
      <div class="table_box_item">
        <tableJd
          :dataList="data_selectOrderReceive"
          @timeChanage="timeChanage"
        />
      </div>

      <div class="table_box_item">
        <tableWg
          :dataList="data_selectOrderFinish"
          @timeChanage="timeChanage"
        />
      </div>

      <div class="table_box_item">
        <tableSc
          :dataList="data_selectOrderProduce"
          @timeChanage="timeChanage"
        />
      </div>
      <div class="table_box_item">
        <tableFh :dataList="data_selectOrderShip" @timeChanage="timeChanage" />
      </div>
      <div class="table_box_item">
        <tableYc
          :dataList="data_selectStoreException"
          @timeChanage="timeChanage"
        />
      </div>
      <div class="table_box_item">
        <tableYq
          :dataList="data_selectProduceException"
          @timeChanage="timeChanage"
        />
      </div>
      <div class="table_box_item">
        <tableWc
          :dataList="data_selectWorkerOrderFinish"
          @timeChanage="timeChanage"
        />
      </div>
      <div class="table_box_item">
        <tableBzcn
          :dataList="data_selectTeamGroupCapacity"
          @timeChanage="timeChanage"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { formatDate } from "@/utils/index";

import {
  selectOrderReceive,
  selectOrderProduce,
  selectOrderShip,
  selectStoreException,
  selectOrderFinish,
  selectProduceException,
  selectWorkerOrderFinish,
  selectTeamGroupCapacity,
} from "@/api/system/post";

// 接单
import tableJd from "./components/tableJd.vue";
// 生产
import tableSc from "./components/tableSc.vue";
// 发货
import tableFh from "./components/tableFh.vue";
// 异常
import tableYc from "./components/tableYc.vue";
// 完工
import tableWg from "./components/tableWg.vue";
// 延期
import tableYq from "./components/tableYq.vue";
// 完成
import tableWc from "./components/tableWc.vue";
// 班组产能
import tableBzcn from "./components/tableBzcn.vue";

export default {
  props: {},
  data() {
    return {
      data_selectOrderReceive: [],
      data_selectOrderProduce: [],
      data_selectOrderShip: [],
      data_selectStoreException: [],
      data_selectOrderFinish: [],
      data_selectProduceException: [],
      data_selectWorkerOrderFinish: [],
      data_selectWorkerOrderFinish: [],
      data_selectTeamGroupCapacity: [],
    };
  },
  computed: {},
  created() {},
  mounted() {
    this.initTjjd();
    this.initScqk();
    this.initFhqk();
    this.initYcqk();
    this.initWgqk();
    this.initYqqk();
    this.initWcqk();
    this.initBzcn();
  },
  watch: {},
  methods: {
    timeChanage(data) {
      let { funCb, data_ } = data;
      if (!data_) {
        this[funCb]();
        return;
      }
      this[funCb]({
        beginDate: formatDate(data_[0], true),
        endDate: formatDate(data_[1], true),
      });
    },

    // 接单列表
    async initTjjd(isWhere = {}) {
      let temRes = await selectOrderReceive(isWhere);
      this.data_selectOrderReceive = temRes.data;
    },
    // 生成列表
    async initScqk(isWhere = {}) {
      let temRes = await selectOrderProduce(isWhere);
      this.data_selectOrderProduce = temRes.data;
    },
    // 发货情况列表
    async initFhqk(isWhere = {}) {
      let temRes = await selectOrderShip(isWhere);
      this.data_selectOrderShip = temRes.data;
    },
    // 发货异常列表
    async initYcqk(isWhere = {}) {
      let temRes = await selectStoreException(isWhere);
      this.data_selectStoreException = temRes.data;
    },

    // 完工列表
    async initWgqk(isWhere = {}) {
      let temRes = await selectOrderFinish(isWhere);
      this.data_selectOrderFinish = temRes.data;
    },

    // 延期
    async initYqqk(isWhere = {}) {
      let temRes = await selectProduceException(isWhere);
      this.data_selectProduceException = temRes.data;
    },
    // 完成
    async initWcqk(isWhere = {}) {
      let temRes = await selectWorkerOrderFinish(isWhere);
      this.data_selectWorkerOrderFinish = temRes.data;
    },
    // 班组产能
    async initBzcn(isWhere = {}) {
      let temRes = await selectTeamGroupCapacity(isWhere);
      this.data_selectTeamGroupCapacity = temRes.data;
    },
  },
  components: {
    tableJd,
    tableSc,
    tableFh,
    tableYc,
    tableWg,
    tableYq,
    tableWc,
    tableBzcn,
  },
};
</script>

<style lang="scss">
.table_title {
  padding: 8px;
  display: flex;
  align-items: center;
  .table_title_time {
    margin-left: 10px !important;
  }
}
</style>
<style scoped lang="scss">
.table_box {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0 10px;
  .table_box_item {
    width: 49%;
    margin-top: 14px;
    &:nth-child(-1n + 2) {
      margin-top: 0;
    }
  }
}
</style>
